<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="C" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>新闻列表-CAS官网</title>
		<link rel="stylesheet" href="css/iconfont.css" />
		<link rel="shortcut icon" href="img/favicon.ico" />
		<link rel="stylesheet" href="css/admin.css" />
		<link rel="stylesheet" href="css/userlist.css" />
		<link rel="stylesheet" href="css/newslist_admin.css" />
		<script type="text/javascript" src="js/jquery-3.2.0.min.js"></script>
		<script type="text/javascript" src="js/admin.js"></script>
		<script type="text/javascript" src="js/ListNews.js"></script>
	</head>

	<body>
		<div class="g-left">
			<ul class="m-nav">
				<C:forEach items="${menulist }" var="menu">
					<C:if test="${menu.permission<=role && menu.permission!=0 }">
						<C:choose>
							<C:when test="${menu.name == '新闻管理' }">
								<li class="m-active">
									<span><i class="icon iconfont">&#xe612;</i>${menu.name }<i class="icon iconfont">&#xe601;</i></span>
									<ul>
										<C:forEach items="${menulist }" var="menu1">
											<C:if test="${menu.id == menu1.pid }">
												<C:choose>
													<C:when test="${menu1.permission<=role && menu.permission!=0 && menu1.name=='新闻列表'}">
														<li class="m-li-active">
															<a href="${menu1.url }">${menu1.name }</a>
														</li>
													</C:when>
													<C:otherwise>
														<li>
															<a href="${menu1.url }">${menu1.name }</a>
														</li>
													</C:otherwise>
												</C:choose>
											</C:if>
										</C:forEach>
									</ul>
								</li>
							</C:when>
							<C:otherwise>
								<C:if test="${menu.pid == 0}">
									<li>
										<span><i class="icon iconfont">&#xe612;</i>${menu.name }<i class="icon iconfont">&#xe601;</i></span>
										<ul>
											<C:forEach items="${menulist }" var="menu1">
												<C:if test="${menu.id == menu1.pid && menu1.permission<=role && menu.permission!=0}">
													<li>
														<a href="${menu1.url }">${menu1.name }</a>
													</li>
												</C:if>
											</C:forEach>
										</ul>
									</li>
								</C:if>
							</C:otherwise>
						</C:choose>
					</C:if>
				</C:forEach>
			</ul>
		</div>
		<div class="g-right">
			<div class="g-status">
				<i class="icon iconfont m-switch">&#xe606;</i>
				<div>
					<i class="icon iconfont m-switch">&#xe602;</i>
					<a href="index.jsp">前台</a>
					<i class="icon iconfont m-switch">&#xe6a0;</i>
					<span>管理员:</span>
					<a href="">张三</a>
					<i class="icon iconfont m-switch">&#xe60e;</i>
					<a href="">安全退出</a>
				</div>
			</div>
			<div class="g-mn">
				<div class="m-breadcrumb">
					<span><a href="">首页</a></span>
					<span>></span>
					<span><a href="">新闻管理</a></span>
					<span>></span>
					<span><a href="">新闻列表</a></span>
				</div>
				<table class="m-table">
					<thead>
						<tr>
							<th>序号</th>
							<th>新闻标题</th>
							<th>作者</th>
							<th>查看</th>
							<th>删除</th>
						</tr>
					</thead>
					<tbody>
						<%int i = 1; %>
						<C:forEach items="${allNews }" var="news">
							<tr>
								<td><%=i++ %></td>
								<td style="max-width:800px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" onclick="viewnews('${news.newsid}')">${news.title }</td>
								<td>${news.author }</td>
								<td onclick="viewnews('${news.newsid}')"><i class="icon iconfont">&#xe845;</i></td>
								<td onclick="deletenews('${news.newsid }','${news.title}')"><i class="icon iconfont">&#xe6e5;</i></td>
							</tr>
						</C:forEach>
					</tbody>
				</table>
				<div class="m-page">
					每页显示<input type="text" value="${pageSize }" />/${count }条记录
					<a href="ListNews.do?pageindex=1&pagesize=${pageSize }">
						<<</a>
							<a href="ListNews.do?pageindex=${pageIndex-1 }&pagesize=${pageSize }">
								<</a>
									<C:forEach var="j" begin="${1 }" end="${3 }" step="1">
										<C:if test="${pageIndex-4+j>0 }">
											<a href="ListNews.do?pageindex=${pageIndex-4+j }&pagesize=${pageSize }">${pageIndex-4+j }</a>
										</C:if>
									</C:forEach>
									<a href="ListNews.do?pageindex=${pageIndex }&pagesize=${pageSize }" class="m-current-page">${pageIndex }</a>
									<C:forEach var="k" begin="${1 }" end="${4 }" step="1">
										<C:if test="${pageIndex+k<=maxPageSize }">
											<a href="ListNews.do?pageindex=${pageIndex+k }&pagesize=${pageSize }">${pageIndex+k }</a>
										</C:if>
									</C:forEach>
									<C:if test="${pageIndex+5<maxPageSize}">
										<a href="ListNews.do?pageindex=${pageIndex+5 }&pagesize=${pageSize }">...</a>
									</C:if>
									<C:if test="${pageIndex+4<maxPageSize }">
										<a href="ListNews.do?pageindex=${maxPageSize }&pagesize=${pageSize }">${maxPageSize }</a>
									</C:if>
									<a href="ListNews.do?pageindex=${pageIndex+1 }&pagesize=${pageSize }">></a>
									<a href="ListNews.do?pageindex=${maxPageSize }&pagesize=${pageSize }">>></a>
				</div>
			</div>
		</div>

	</body>

</html>